
import OrganAPI from '../api/organ.js';

export const Organ={
   state:{
      editOrganStatus:-1,     //插入状态 0失败  1成功  -1不改变
      organinfo:[],
   },
   mutations:{
      setEditOrganStatus(state,status){
          state.editOrganStatus=status;
      },
      setOrganInfo(state,info){
          state.organinfo=info;
      }
   },
   actions:{
      //插入Organ
      editOrgan(context,data){
          OrganAPI.editOrgan(data).then(function(response){
              context.commit('setEditOrganStatus',response.data.code);
          })
      },
      //获取详情
      loadOrganInfo(context,data){
          OrganAPI.getOrganInfo(data).then(function(response){
              if(response.data.code==1){
                  context.commit('setOrganInfo',response.data.info);
              }
          })
      }
   },
   getters:{
      getEditOrganStatus:state=>{
          return state.editOrganStatus;
      },
      getOrganInfo:state => {
          return state.organinfo;
      }
   }
}
